const Monitor = require('../../utils/monitor.js').Monitor
const util = require('../../utils/util.js')
Page(Monitor.hookApp({
  data: {
    qingdan: `${getApp().globalData.imgUrl}jsy-newshop清单.svg`,
    tijiao: `${getApp().globalData.imgUrl}jsy-newshop提交成功.svg`,
    daiFaHuo: true, //商家配送 && 同城限时达   -->   代发货
    daiShouHuo: false, //商家配送 && 同城限时达   -->   待收货
    daoDianZiTiBeiHuo: false, //到店自提          -->   商家备货
    daoDianZiTiHeXiaoWanCheng: false, //到店自提          -->   核销完成
    isSJPS: false,
    isTCXSD: false,
    isDDZT: false,
  },
  jumpOrder() {
    wx.navigateTo({
      url: '../dingDanList/dingDanList?status=99',
    })
  },
  goon() {
    var pages = getCurrentPages();
   
    wx.navigateBack({
      delta: pages.length - 1
    })
  },
  onLoad(o) {
    console.log(o,123123123)
    this.setData({
      distribution: o.distribution,
      order_id: o.order_id,
      from: o.from || 'success'
    })
    if (this.data.distribution == 1) {
      this.setData({
        isSJPS: true
      })
    } else if (this.data.distribution == 2) {
      this.setData({
        isTCXSD: true
      })
    } else if (this.data.distribution == 3) {
      this.setData({
        isDDZT: true
      })
    }
  },
  onShow() {
    this.geiPageInfo()
  },
  geiPageInfo() {
    util.API('pyapi/oder_if', {
      order_id: this.data.order_id
    }, 'application/x-www-form-urlencoded').then(res => {
      console.log(res)
      let {
        code,
        data,
        orders_goods_list,
        address,
        address_info
      } = res
      if (code == 200) {
        this.setData({
          pageData: data,
          orders_goods_list,
          address,
          address_info
        })
      }
    })
  },
  
  onUnload: function () {
    if (this.data.from == 'success'){
      wx.navigateBack({
        delta: 1
      })
    } else if (this.data.from == 'faile'){
      wx.navigateBack({
        delta: 2
      })
    }
  }
}))